<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <!-- v-model 修饰符 -->
      <!-- .lazy   v-model每次更新数据是输入框中的值与数据进行同步更新 使用.lazy则是输入框失去焦点后数据进行更新-->
    <input type="text" v-model.lazy="msg">
    <h1>{{msg}}</h1>
    <!-- .number 将输入内容转为数字 -->
    <input type="text" v-model.number="str">
    <h1>{{mystr}}</h1>
    <!-- .trim() 去除首尾空格 -->
    <input type="text" v-model="myname">
    <h1>{{myname}}</h1>
    <hr>
    <!-- v-model收集复选框的数据 -->
    吃 <input type="checkbox" value="chi" v-model="cks"  name="aihao">
    喝<input type="checkbox" value="he" v-model="cks"  name="aihao">
    玩<input type="checkbox" value="wan"  v-model="cks"  name="aihao">
    <button @click="send">收集</button>
  </div>   
  <script src="./vue.js"></script>
  <script>
    new Vue({
      el:"#app",
      data(){
        return {
          msg:"",
          str:"",
          myname:"",
          cks:[] //收集复选框数据的数组
        }
      },
    methods: {
      send(){
        console.log(this.cks)
      }
    },
    computed:{
      mystr(){
        let s=this.str+1;
        console.log(this.str)
        return s
      }
      }
    })
  </script>
</body>
</html>